from pydantic import BaseModel, Field, ConfigDict


class EnumItemBase(BaseModel):
    value: str = Field(..., description="枚举值")
    label: str = Field(..., description="显示文本")
    sort_order: int = Field(0, ge=0, description="排序")
    status: int = Field(1, ge=0, le=1, description="1启用 0禁用")
    ext_json: dict | None = None


class EnumItemCreate(EnumItemBase):
    type: str = Field(..., description="枚举类型名称，如DeviceType、AlarmType等", max_length=32)


class EnumItemUpdate(BaseModel):
    value: str | None = None
    label: str | None = None
    sort_order: int | None = None
    status: int | None = None
    ext_json: dict | None = None


class EnumItemOut(EnumItemBase):
    id: int
    type_id: int

    model_config = ConfigDict(from_attributes=True)
